<!doctype html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
</head>
<body>

{include file="public/header"}



<div class="content">
    <div class="main-wrap">
        <form action="{:url('edit')}" class="parsley-validate" enctype="multipart/form-data" method="post">
            <input type="hidden" name="id" value="{$data['id']}">
            <div class="form-group-col-2">
                <div class="form-label">活动标题:</div>
                <div class="form-cont">
                    <input type="text" name="activity_title" value="{$data['activity_title']}"  placeholder="活动标题..." class="form-control form-boxed"   />
                </div>
            </div>

            <div class="form-group-col-2">

                <div class="form-label">活动图片:</div>
                <div class="form-cont" >
                    <input type="file" name="image" id="file0"  /><br><p style="color:#ccc">(图片大小为 1MB 以内,长:400px,宽:150px)</p>
                    <img src="/vdma/public/uploads/{$data['activity_img']}" id="img0" style="width: 150px">
                </div>
            </div>

            <!-- <div class="form-group-col-2">
                <div class="form-label">活动内容:</div>
                <div class="form-cont">
                    <input type="text" name="activity_content" value="{$data['activity_content']}"  placeholder="活动内容" class="form-control form-boxed"   />
                </div>
            </div> -->

            <div class="form-group-col-2">
                <div class="form-label">活动地点:</div>
                <div class="form-cont">
                    <input type="text" name="activity_place" value="{$data['activity_place']}"  placeholder="活动地点" class="form-control form-boxed"   />
                </div>
            </div>

            <div class="form-group-col-2">
                <div class="form-label">活动时间:</div>
                <div class="form-cont">
                    <input type="text" name="activity_time" value="{$data['activity_time']}"  placeholder="活动时间" class="form-control form-boxed"   />
                </div>
            </div>

            <div class="form-group-col-2">
                <div class="form-label">活动链接:</div>
                <div class="form-cont">
                    <input type="text" name="activity_link" value="{$data['activity_link']}"  placeholder="活动链接" class="form-control form-boxed"   /><p style="color:#ccc">(请从 "http"或"https" 开始)</p>
                </div>
                </div>
            </div>

            <!-- <div class="form-group-col-2">
                <div class="form-label">活动状态:</div>
                <div class="form-cont">
                    <input type="text" name="statuid" value="{$data['statuid']}"  placeholder="状态...1正常0失效" class="form-control form-boxed"   />
                </div>
            </div> -->




            <div class="form-group-col-2">
                <div class="form-label"></div>
                <div class="form-cont">
                    <input type="submit" class="btn btn-primary" value="保存"/>
                </div>
            </div>

        </form>
    </div>
</div>


<!--form validation js -->
<script src="__STATIC__/js/common/jquery.js"></script>
<script src="__STATIC__/js/parsley.js"></script>
<script src="__STATIC__/js/zh_cn.js"></script>
<script>
    $('.parsley-validate').parsley();//调用parsley表单验证插件
</script>
<!--图预览及上传-->
<script>
    $("#file0").change(function(){
        // getObjectURL是自定义的函数，见下面
        // this.files[0]代表的是选择的文件资源的第一个，因为上面写了 multiple="multiple" 就表示上传文件可能不止一个
        // ，但是这里只读取第一个
        var objUrl = getObjectURL(this.files[0]) ;
        // 这句代码没什么作用，删掉也可以
        // console.log("objUrl = "+objUrl) ;
        if (objUrl) {
            // 在这里修改图片的地址属性
            $("#img0").attr("src", objUrl) ;
        }
    }) ;
    //建立一個可存取到該file的url
    function getObjectURL(file) {
        var url = null ;
        // 下面函数执行的效果是一样的，只是需要针对不同的浏览器执行不同的 js 函数而已
        if (window.createObjectURL!=undefined) { // basic
            url = window.createObjectURL(file) ;
        } else if (window.URL!=undefined) { // mozilla(firefox)
            url = window.URL.createObjectURL(file) ;
        } else if (window.webkitURL!=undefined) { // webkit or chrome
            url = window.webkitURL.createObjectURL(file) ;
        }
        return url ;
    }

</script>

</body>
</html>